﻿using System;
using System.Collections.Generic;
using System.Linq;
using OpenTwitt.Resources;

namespace OpenTwitt.Handlers
{
	public class UserHandler
	{
		private static IList<UserResource> Users = CreateDefaultUsers();

		private static IList<UserResource> CreateDefaultUsers()
		{
			var andrea = new UserResource()
			             	{
								Username = "andrea",
			             		Messages = new List<MessageResource>()
			             		           	{
			             		           		new MessageResource() {Id = 1, Twitt = "Something"},
			             		           		new MessageResource() {Id = 2, Twitt = "Something else"}
			             		           	}
			             	};
			var david = new UserResource()
			            	{
			            		Username = "david",
			            		Messages = new List<MessageResource>()
			            		           	{
			            		           		new MessageResource() {Id = 1, Twitt = "Something"},
			            		           		new MessageResource() {Id = 2, Twitt = "Something else"}
			            		           	}

			            	};
			david.Follows.Add(andrea);
			andrea.Follows.Add(david);
			return new List<UserResource>
			       	{
			       		andrea,
			       		david
			       	};
		}


		public object Get(string username)
		{
			return Users.First(u => u.Username == username );
		}

	}
}
